import pymysql
# 创建数据库连接
db = pymysql.connect(
    host="localhost",
    port=3306,
    user="root",
    password="",
    charset="utf8"
)
cursor = db.cursor()

cursor.execute("select version()")

print(cursor)
# fetchone()方法用来获取一条数据:字符电
data = cursor.fetchone()
print("当前数据库版本%s"% data)
cursor.close();

db.close();